package com.team.mp.api.controller;

import com.team.mp.api.bo.ServiceSearchBo;
import com.team.mp.api.bo.SignRecordSearchBo;
import com.team.mp.api.service.intf.SignRecordService;
import com.team.mp.mapper.entity.SignRecord;
import com.team.mp.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: Lixiang
 * @date: 2023/3/27 22:00
 * @description:
 * @version:
 */
@RestController
@RequestMapping("/api/signrecord")
@Api(tags = "签约记录")
public class SignRecordController {

    /**
     * 注入业务逻辑层对象
     */
    @Resource
    private SignRecordService service;
    /**
     * 新增内容*/
    @ApiOperation(value = "实现新增")
    @PostMapping("save.do")
    public R save(@RequestBody SignRecord signRecord){
        return service.save(signRecord);
    }
    /**
     * 修改内容
     */
    @ApiOperation(value = "实现修改")
    @PostMapping("update.do")
    public R update(@RequestBody SignRecord signRecord) {
        return service.update(signRecord);
    }

    /**
     * 查询 所有数据
     */
    @ApiOperation(value = "实现全部查询")
    @GetMapping("all.do")
    public R all() {
        return service.queryAll();
    }
    /**
     * 查询 详细数据
     */
    @ApiOperation(value = "查询详细数据")
    @GetMapping("querydetail.do")
    public R querydetail(Integer id) {
        return service.queryById(id);
    }

    @ApiOperation(value = "查询待处理记录")
    @PostMapping("unhandledrecord.do")
    public R query(@RequestBody SignRecordSearchBo bo, int page, int size) {
        if (bo.getSignStatus() < 4) {
            return R.ok(service.queryByCond(page, size, bo));
        }
        return R.fail("签约状态条件异常");
    }

    @ApiOperation(value = "查询已处理签约记录")
    @PostMapping("record.do")
    public R query1(@RequestBody SignRecordSearchBo bo, int page, int size) {
        if (bo.getSignStatus() > 3) {
            return R.ok(service.queryByCond(page, size, bo));
        }
        return R.fail("签约状态条件异常");
    }

    @ApiOperation(value = "导出")
    @PostMapping("output.do")
    public R output(HttpServletResponse response) {
        return R.ok(service.output(response));
    }

    @ApiOperation(value = "查询详细数据1")
    @PostMapping("querybyid.do")
    public R queryById(long id){
        return R.ok(service.queryById1(id));
    }
    @ApiOperation(value = "申请通过")
    @PostMapping("pass.do")
    public R pass(Integer id){
        return R.ok(service.pass(id));
    }
    @ApiOperation(value = "申请驳回")
    @PostMapping("reject.do")
    public R reject(Integer id){
        return R.ok(service.reject(id));
    }


    @ApiOperation(value = "居民点击立即签约按钮请求的方法")
    @GetMapping("before.do")
    public R before(int id){
        return service.before(id);
    }

    @ApiOperation(value = "居民模块下的签约信息详情展示")
    @GetMapping("rsignd.do")
    public R rsignd(int rid) {
        return service.rsignd(rid);
    }

    @ApiOperation(value = "居民模块下的签约记录列表展示")
    @GetMapping("rsignlist.do")
    public R rsignlist(int rid) {
        return service.rsignlist(rid);
    }
}
